<%--
  Created by IntelliJ IDEA.
  User: wwh
  Date: 2017/7/28
  Time: 19:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="admin-main">
    <div id="teacher">
        <fieldset class="layui-elem-field">
            <legend>选择指导教师</legend>
            <div class="layui-field-box">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">请选择：</label>
                            <div class="layui-input-inline">
                                <select name="teachers" lay-filter="chooseTeacher" id="chooseTeacher" style="overflow: auto" lay-search>
                                    <option value="">请选择...</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <button lay-filter="saveTeacher" class="layui-btn" lay-submit>确认</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>
</div>

<script>
var schoolId=<%=request.getParameter("schoolId")%>;
var teacherType = <%=request.getParameter("teacherType")%>;
var teachers = [];
console.log(schoolId+"   "+teacherType);
</script>
<script>
layui.use(['form','jquery'],function () {
    var form = layui.form(),
        $ = layui.jquery
    /**
     * 首次读取信息
     */
    $.ajax({
        type: "POST"
        , url: "/teacherInfo/findDetailBatchBySchoolIdCondition"
        , contentType: "application/json; charset=utf-8"
        , data:JSON.stringify({schoolid:schoolId})
        , success: function (Response) {
            console.log(Response.data);
            for (var i = 0; i < Response.data.length; i++) {
                teachers[i] = Response.data[i];
            }
            console.log(teachers);
            var html = '';
            for (var i = 0; i < teachers.length; i++) {
                html += '<option value=' + teachers[i].teacherInfo.id + ' >' + teachers[i].user.realname + '</option>';
                // console.log(html);
            }
            $("#chooseTeacher").append(html);
            form.render('select');
        }
        , error: function (msg) {
            console.log("获取教师信息失败");
            console.log(msg);
        }
    });


});
</script>
